//
//  BaseTabbarViewController.m
//  JobFree2.0
//
//  Created by xxcao on 2017/5/27.
//  Copyright © 2017年 Dale. All rights reserved.
//

#import "BaseTabbarViewController.h"
#import "JFNoteViewController.h"
#import "JFDynamicViewController.h"
#import "JFArchiveViewController.h"
#import "JFBoardSettingViewController.h"
#import "BaseNavigationViewController.h"

@interface BaseTabbarViewController ()

@end

@implementation BaseTabbarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:animated];

}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}

- (void)loadViewControllers {
    
    JFNoteViewController *noteVC = [[JFNoteViewController alloc] initWithNibName:@"JFNoteViewController" bundle:nil];
    BaseNavigationViewController *noteNC = [[BaseNavigationViewController alloc] initWithRootViewController:noteVC];
    UITabBarItem *noteTabBarItem = [[UITabBarItem alloc] initWithTitle:@"看板" image: [UIImage imageNamed:@"preworkIcona"] selectedImage:[UIImage imageNamed:@"preworkIconb"]];
    noteTabBarItem.tag = 0;
    noteNC.tabBarItem = noteTabBarItem;
    

    JFDynamicViewController *dynamicVC = [[JFDynamicViewController alloc] initWithNibName:@"JFDynamicViewController" bundle:nil];
    BaseNavigationViewController *dynamicNC = [[BaseNavigationViewController alloc] initWithRootViewController:dynamicVC];
    UITabBarItem *dynamicTabBarItem = [[UITabBarItem alloc] initWithTitle:@"动态" image: [UIImage imageNamed:@"dynamicIcona"] selectedImage:[UIImage imageNamed:@"dynamicIconb"]];
    dynamicTabBarItem.tag = 1;
    dynamicNC.tabBarItem = dynamicTabBarItem;

    
    JFArchiveViewController *archiveVC = [[JFArchiveViewController alloc] initWithNibName:@"JFArchiveViewController" bundle:nil];
    BaseNavigationViewController *archiveNC = [[BaseNavigationViewController alloc] initWithRootViewController:archiveVC];
    UITabBarItem *archiveTabBarItem = [[UITabBarItem alloc] initWithTitle:@"归档" image: [UIImage imageNamed:@"archiveIcona"] selectedImage:[UIImage imageNamed:@"archiveIconb"]];
    archiveTabBarItem.tag = 2;
    archiveNC.tabBarItem = archiveTabBarItem;

    
    JFBoardSettingViewController *settingVC = [[JFBoardSettingViewController alloc] initWithNibName:@"JFBoardSettingViewController" bundle:nil];
    settingVC.model = self.model;
    BaseNavigationViewController *settingNC = [[BaseNavigationViewController alloc] initWithRootViewController:settingVC];
    UITabBarItem *settingTabBarItem = [[UITabBarItem alloc] initWithTitle:@"设置" image: [UIImage imageNamed:@"settingIcona"] selectedImage:[UIImage imageNamed:@"settingIconb"]];
    settingTabBarItem.tag = 3;
    settingNC.tabBarItem = settingTabBarItem;

    
    // 5.新建一个导航控制器实例的数组
    NSArray *controllersArray = @[noteNC, dynamicNC, archiveNC, settingNC];
    // 6.把导航控制器的数组加入到标签控制器
    [self setViewControllers:controllersArray animated:YES];
    self.tabBar.tintColor = [UIColor colorWithRed:19.0 / 255.0 green:150.0 / 255.0 blue:159.0 / 255.0 alpha:1.0];
}

@end
